<template>
  <div>
    <eagle-input
      class="input_text"
      label="下级单位"
      v-model="form.EnterpriseName"
      name="EnterpriseName"
      readonly
    >
    </eagle-input>

    <eagle-input
      class="input_text"
      label="最近修改人"
      v-model="form.EditChnName"
      name="EditChnName"
      readonly
    >
    </eagle-input>
    <eagle-input
      class="input_text"
      label="年份"
      v-model="form.Year"
      name="Year"
      readonly
    >
    </eagle-input>
    <eagle-input
      label="事故日期"
      :value="form.EditDate|formatDateTime"
      readonly
    ></eagle-input>
    <eagle-input
      label="签名文件"
      class="input_text_block"
    >
      <template #input>
        <div
          v-for="(item, index) in MainAttach"
          :key="index"
          class="wrapper space-between mb-10"
        >
          <a
            style="color: blue"
            @click.stop="goFile(item.AttCode)"
          >
            {{ item.AttName }}{{ item.AttExt }}</a>
        </div>
      </template>
    </eagle-input>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import FileListReadOnly from "../../../components/Attach/FileListReadOnly.vue";
export default {
  components: {},
  components: { FileListReadOnly },
  data() {
    return {
      id: this.$route.query.id,
      form: {},
      MainAttach: {},
    };
  },

  computed: {
    ...mapGetters(["baseUrl", "CompanyCode", "roles"]),
  },

  created() {
    if (this.$route.query.id != null) {
      (this.id = this.$route.query.id), this.getDetail();
    }

    console.log("id", this.$route.query.id);
  },
  methods: {
    goFile(attachCode) {
      this.$router.push("/Attach/AatachDetail?attCode=" + attachCode);
    },
    getDetail(certId) {
      let params = { id: this.id };

      this.$axios
        .get("/ResponsibilityOrgPostUserDepositManage/GetDetail", {
          params: params,
        })
        .then((res) => {
          if (res.data.Attachs) {
            let Attachs = res.data.Attachs.split(";");
            console.log(Attachs, "Attachs");
            res.data.Attachs = JSON.parse(res.data.Attachs);
          } else {
            res.data.Attachs = [];
          }
          this.form = res.data;
          this.MainAttach = JSON.parse(res.data.MainAttach.replace(/'/g, '"'));
        });
    },
  },
};
</script>

<style lang="less" >
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.block {
  width: 120px;
  height: 120px;
  background-color: #fff;
}
</style>
<style lang="less" scoped>
.space-between {
  justify-content: space-between;
}
</style>
